package com.breeze.components.task.lock;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.util.concurrent.TimeUnit;
import org.springframework.core.annotation.AliasFor;
import org.springframework.scheduling.annotation.Scheduled;

/**
 * Scheduled注解包装，集群环境只执行一次
 *
 * @author breeze
 */
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@Scheduled
public @interface LockScheduled {

  String value();

  @AliasFor(annotation = Scheduled.class)
  String cron() default "";

  @AliasFor(annotation = Scheduled.class)
  String zone() default "";

  @AliasFor(annotation = Scheduled.class)
  long fixedDelay() default -1L;

  @AliasFor(annotation = Scheduled.class)
  String fixedDelayString() default "";

  @AliasFor(annotation = Scheduled.class)
  long fixedRate() default -1L;

  @AliasFor(annotation = Scheduled.class)
  String fixedRateString() default "";

  @AliasFor(annotation = Scheduled.class)
  long initialDelay() default -1L;

  @AliasFor(annotation = Scheduled.class)
  String initialDelayString() default "";

  @AliasFor(annotation = Scheduled.class)
  TimeUnit timeUnit() default TimeUnit.MILLISECONDS;
}
